#include <stdio.h>
#include <stdlib.h>
#include <conio.h> 
#include"Student.h"
void welcome(){
	printf("========考生查询系统========\n");
	printf("1.添加考生\n");
	printf("2.初试复试\n");
	printf("3.录取情况\n");
	printf("4.考生查询\n");
	printf("===========================\n");
}



void addfiles(){
	char selectYNFlag = 'y';
	int filesCount = 0;//记录考生人数 
	while(selectYNFlag == 'Y' || selectYNFlag == 'y'){
		printf("\n请输入考生考号；");
		scanf("%d",fileslist[filesCount].id);
		printf("\n请输入考生姓名；");
		scanf("%s",fileslist[filesCount].name);
		printf("\n请输入考生性别；");
		scanf("%s",fileslist[filesCount].gender);
		printf("\n请输入考生年龄；");
		scanf("%d",fileslist[filesCount].age);
		printf("\n请输入考生政治面貌；");
		scanf("%s",fileslist[filesCount].outlook);
		printf("\n请输入考生应届是否；");
		scanf("%s",fileslist[filesCount].current);
		printf("\n请输入考生学历；");
		scanf("%s",fileslist[filesCount].edu);
		printf("\n请输入考生来源；");
		scanf("%s",fileslist[filesCount].source);
		printf("\n请输入考生报考专业；");
		scanf("%s",fileslist[filesCount].applymajors);
		printf("\n请输入考生报考类别；");
		scanf("%s",fileslist[filesCount].applycategory);
		
		filesCount++;
		printf("是否继续录入：");
		getchar();
		scanf("%c", &selectYNFlag);
	}
	printf("\n今年共有%d名考生",filesCount);
}



void input()
{
	Node* pNewNode = (Node*)malloc(sizeof(Node));
	pNewNode->pNext = NULL;
	if(g_pHead == NULL)
	{
		g_pHead = pNewNode;
	}
	else
	{
		pNewNode->pNext = g_pHead;
		g_pHead = pNewNode;
	}	
	
	char selectYNFlag4 = 'y';
	while(selectYNFlag4 == 'Y' || selectYNFlag4 == 'y'){
	    printf("\n请输入考生考号；");
		scanf("%d",&pNewNode->stu.id0);
		printf("\n请输入考生姓名；");
		scanf("%s",pNewNode->stu.name2);
		printf("\n请输入考生政治成绩；");
		scanf("%d",&pNewNode->stu.politics);
		printf("\n请输入考生外语成绩；");
		scanf("%d",&pNewNode->stu.foreign_language);
		printf("\n请输入考生专业基础科目成绩；");
		scanf("%d",&pNewNode->stu.professional_base);
		printf("\n请输入考生总成绩；");
		scanf("%d",&pNewNode->stu.sum0);
		
			printf("是否继续录入：");
		getchar();
		scanf("%c", &selectYNFlag4);
	}
	
	
	int studentCount = 0;
	Node* p = g_pHead;
	while (p != NULL)
	{
		studentCount++;
		p = p->pNext;
	}

		
	int politicsmin = 0;
	int foreign_languagemin = 0;
	int professional_basemin = 0; 
	int sum0min = 0;
	    printf("\n请输入政治合格成绩；");
		scanf("%d",&politicsmin);
		printf("\n请输入外语合格成绩；");
		scanf("%d",&foreign_languagemin);
		printf("\n请输入专业基础科目合格成绩；");
		scanf("%d",&professional_basemin);
		printf("\n请输入总合格成绩；");
		scanf("%d",&sum0min);
		
	int j;
	int pass1 = 0;
    for(j = 0;j < studentCount;j++){
    	if(pNewNode->stu.politics >= politicsmin)
		{
    		if(pNewNode->stu.foreign_language >= foreign_languagemin)
			{
    			if(pNewNode->stu.professional_base >= professional_basemin)
				{
					if(pNewNode->stu.sum0 >= sum0min)
			         {
    					printf("\n%s通过初试",pNewNode->stu.name2); 
    					pass1++;
					}else{
						printf("\n%s没有通过初试",pNewNode->stu.name2);
					}
				}
				else{
						printf("\n%s没有通过初试",pNewNode->stu.name2);
					}
				}
				else{
						printf("\n%s没有通过初试",pNewNode->stu.name2);
					}
			}else{
						printf("\n%s没有通过初试",pNewNode->stu.name2);
					}
	
	}
	printf("\n有%d人通过初试",pass1);
	
	char selectYNFlag1 = 'y';
	int studentCount2 = 0;//记录考生人数 
	while(selectYNFlag1 == 'Y' || selectYNFlag1 == 'y'){
	
	    
		printf("\n请输入考生专业成绩；");
		scanf("%d",pNewNode->stu.spe);
		printf("\n请输入考生面试成绩；");
		scanf("%d",pNewNode->stu.face);
		printf("\n请输入考生机考成绩；");
		scanf("%d",pNewNode->stu.Comp);
		printf("\n请输入考生总成绩；");
		scanf("%d",pNewNode->stu.sum1);
		
		
		studentCount2++;
		printf("是否继续录入：");
		getchar();
		scanf("%c", &selectYNFlag1);
	}
		
   
	int sum1min = 0; 
	    printf("\n请输入合格成绩；");
		scanf("%d",&sum1min);
		
	int i;
	int pass2 = 0;
	for(i = 0;i < studentCount2;i++)
	{
		if(pNewNode->stu.sum1 >= sum1min){
    					printf("\n%s通过复试",pNewNode->stu.name2);
    					pass2++;
	}
}
	printf("\n有%d人通过复试",pass2);
		
		
}



void adm()
{
	char selectYNFlag2 = 'y';
	int studentCount3 = 0;
	
	while(selectYNFlag2 == 'Y' || selectYNFlag2 == 'y'){
	
	    
		printf("\n请输入录取生姓名；");
		scanf("%s",pupillist[studentCount3].name3);
		printf("\n请输入录取生成绩；");
		scanf("%d",pupillist[studentCount3].score1);
		printf("\n请输入录取生年龄；");
		scanf("%d",pupillist[studentCount3].age1);
		printf("\n请输入录取生来源；");
		scanf("%s",pupillist[studentCount3].where);
		
		
		studentCount3++;
		printf("是否继续录入：");
		getchar();
		scanf("%c", &selectYNFlag2);
	}
	printf("\n今年共有%d名录取生",studentCount3);
}

Node* Findstudent()
{
	int nStuNum;
	printf("请输入考生学号：\n");
	scanf("%d", &nStuNum);
	
	Node* p = g_pHead;
	while(p != NULL)
	{
		if(p->stu.id0 == nStuNum)
		{
			return p;
		}
		p = p->pNext;
	}
	
	return NULL;
}
